#!/usr/bin/env node

const http = require('https'),      
      cheerio = require('cheerio'),
      log = console.log,
      addr = "https://ke.sifou.com/free",
      baseURL = "https://ke.sifou.com";
http.get(addr,(res)=>{

  let data = '';
  res.on('data',(chunk)=>data += chunk);
  res.on('end',()=>{
  //解析
    console.log(data);
    let $ = cheerio.load(data);
    let courses = $('body').find('h5.card-title>a');

    for(let i=0;i<courses.length;i++){
      log($(courses[i]).text());
      log(baseURL + $(courses[i]).attr('href'));
      log();
    }
     
    });
 

});
